import { IFeidaoAiBrowserComponent } from '../../interfaces';

/**
 * 调用组件事件
 * @param no 被调用的组件编号
 * @param event_name 被调用组件的事件名
 * @param args 参数
 * @return any
 */
export default async function fire(no: string, event_name: string, ...args: any[]) {
	const node = document.querySelector<HTMLElement>(no);
	if (!node) {
		throw new Error(`could not find component:[${no}]`);
	} else {
		return await ((node as any).fd as IFeidaoAiBrowserComponent).emit(event_name, ...args);
	}
}
